import React from "react";
import {Link} from "react-router-dom";
import {usePlayerStoreDispatch, setMusicId} from '@/components/Player/store'

const style = {
    width: "100%",
    objectFit: "cover"
}

const SwiperItem = (props) => {
    const {id, cover, type} = props;
    const dispatch = usePlayerStoreDispatch();

    const handleClick = () => {
        if (type === 1) {
            dispatch(setMusicId(id));
        }
    }

    return (
        <Link to={type === 10 ? "/singlelist/" + id : ""} onClick={handleClick}>
            <img src={cover} style={style} alt=""/>
        </Link>
    );
}

export default SwiperItem;
